/* 
 * Driver for a cardiac elecrophysiology simulation that uses the
 * Aliev-Panfilov model
 * We use an explicit method
 *
 * Based on code orginally provided by Xing Cai, Simula Research Laboratory
 * 
 * Modified and  restructured by Scott B. Baden, UCSD
 * Ported to CUDA by Didem Unat, UCSD
 */

#include <assert.h>
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <iomanip>
#include <string>
#include <math.h>
#include "time.h"
#include "apf.h"
#include "utils.h"
#include "types.h"

#include "latency.cu"
#include "global.cu"
// External functions
void cmdLine(int argc, char *argv[], _DOUBLE_& T, int& n, int& tx, int& ty, int& do_stats, int& plot_freq, int& prefer_l1);

using namespace std;

// Main program
int main(int argc, char** argv)
{
 // Command line arguments
 // Default value of the domain sizes
 _DOUBLE_ T=1500.0;
 int m=100,n=100;
 int do_stats = 0;
 int plot_freq = 0;
 int tx = 1, ty = 1;
 int prefer_l1 = 0;

 cmdLine( argc, argv, T, n, tx, ty, do_stats,  plot_freq, prefer_l1);
 m = n;
 selectAndReport();
  
 int nx = (m+1) / tx, ny = (n+1) / ty;
 // The thread geometry must evenly divide N
 if ((nx * tx != (m+1)) || (ny * ty != (n+1)) )
 {
  printf("Thread geometry: %d x %d\n",tx, ty);
  printf("The length of the thread geometry axis ");
  printf("[ %d x %d]\n",tx, ty);
  printf("  must divide N [%d] evenly\n",m+1);
  exit(-1);
 }
     
 measure_latency();
 //measure_global();

}
